<template>
    <div>
        <nut-button type="success" @click="handleLogin">微信登录</nut-button>

    </div>
</template>

<script>
import { defineComponent, ref, reactive, nextTick, onMounted, toRaw, toRefs, watch, TrackOpTypes } from 'vue'
import Taro from '@tarojs/taro'
export default defineComponent({
    setup() {
        const handleLogin = () => {
            Taro.login({
                success: function (res) {
                    if (res.code) {
                        //发起网络请求
                        Taro.request({
                            url: 'https://test.com/onLogin',
                            data: {
                                code: res.code
                            }
                        })
                    } else {
                        console.log('登录失败！' + res.errMsg)
                    }
                }
            })
            Taro.getUserProfile({
                desc: '用于完善会员资料', // 声明获取用户个人信息后的用途，后续会展示在弹窗中，请谨慎填写
                success: (res) => {
                    // 开发者妥善保管用户快速填写的头像昵称，避免重复弹窗
                    console.log(res)
                }
            })
        }
        return {
            handleLogin
        }
    }
})
</script>
<style scoped lang='scss'></style>